//
//  CarImageTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/3/4.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "CarImageTableViewCell.h"

@interface CarImageTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *leftImage;
@property (weak, nonatomic) IBOutlet UIImageView *midImage;
@property (weak, nonatomic) IBOutlet UIImageView *rightImage;

@end
@implementation CarImageTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.leftImage addTapGestureWithTarget:self action:@selector(clickImage:)];
    [self.midImage addTapGestureWithTarget:self action:@selector(clickImage:)];
    [self.rightImage addTapGestureWithTarget:self action:@selector(clickImage:)];
    self.leftImage.hidden = YES;
    self.midImage.hidden = YES;
    self.rightImage.hidden = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)clickImage:(UIGestureRecognizer *)gesture {
    UIImageView *imageView = (UIImageView *)gesture.view;
    NSInteger index = imageView.tag;
    if (self.BlockClickImage) {
        self.BlockClickImage(index,self.imageArray);
    }
}

- (void)setImageArray:(NSArray *)imageArray {
    _imageArray = imageArray;
    
    for (int i = 0; i < imageArray.count; ++i) {
        NSString *url = [imageArray objectAtIndex:i];
        if ([url isKindOfClass:[NSString class]] && url.length > 0) {
            if (i == 0) {
                [self.leftImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:ImageNamed_bb(@"app_picture_default_img")];
                self.leftImage.hidden = NO;
            }
            else if (i == 1) {
                [self.midImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:ImageNamed_bb(@"app_picture_default_img")];
                self.midImage.hidden = NO;
            }
            else if (i == 2) {
                [self.rightImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:ImageNamed_bb(@"app_picture_default_img")];
                self.rightImage.hidden = NO;
            }
        }
    }
}

- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}

@end
